/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticks.chromedome.commands;
import ticks.chromedome.subsystems.Drive;

/**
 *
 * @author Jared
 */
public class DriveDistance extends CommandBase {
    Drive m_drive;
    double m_distance;
    double m_speed;
    public DriveDistance(double distance, double speed) {
        m_drive = Drive.getInstance();
        requires(m_drive);
        m_distance = distance;
        m_speed = speed;
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        m_drive.resetWheelEncoder();
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        m_drive.setDrive(m_speed, 0);
        
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return m_drive.getWheelEncoder()>m_distance;
    }

    // Called once after isFinished returns true
    protected void end() {
        m_drive.setDrive(0, 0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
        System.out.println("DRIVE DISTANCE HAS BEEN INTERUPTED!");
    }
}
